package luccy.desc;

import java.util.concurrent.ConcurrentHashMap;

import luccy.desc.impl.BeanDescImpl;

public class BeanDescFactory {

	private static ConcurrentHashMap<Class, BeanDesc> cache = new ConcurrentHashMap<Class, BeanDesc>();

	public static <T> BeanDesc<T> getBeanDesc(Class<T> componentClass) {
		BeanDesc<T> beanDesc = cache.get(componentClass);
		if (beanDesc != null) {
			return beanDesc;
		}
		beanDesc = new BeanDescImpl<T>(componentClass);
		cache.put(componentClass, beanDesc);
		return beanDesc;
	}
	
	public static <T> boolean contains(Class<T> componentClass) {
		return cache.containsKey(componentClass);
	}
}
